#ifndef LOADER_H
#define LOADER_H
#define PACKAGE
#define PACKAGE_VERSION
#include <stdint.h>
#include <string>
#include <vector>

enum class SymbolType {
    SYM_TYPE_UKN = 0,
    SYM_TYPE_FUNC = 1
};

enum class SectionType {
    SEC_TYPE_NONE = 0,
    SEC_TYPE_CODE = 1,
    SEC_TYPE_DATA = 2
};

enum class BinaryType {
    BIN_TYPE_AUTO = 0,
    BIN_TYPE_ELF = 1,
    BIN_TYPE_PE = 2
};

enum class BinaryArch {
    ARCH_NONE = 0,
    ARCH_X86 = 1
};

class Binary;

class Symbol {
    public:
        SymbolType type;
        std::string name;
        uint64_t addr;
        Symbol();
        ~Symbol();
};

class Section
{
private:
    /* data */
public:
    Binary *binary;
    std::string name;
    SectionType type;
    uint64_t vma;
    uint64_t size;
    uint8_t *bytes;
    Section(/* args */); 
    ~Section();
};

class Binary
{
private:
    /* data */
public:
    std::string          filename; 
    BinaryType           type; 
    std::string          type_str; 
    BinaryArch           arch;
    std::string          arch_str; 
    unsigned             bits; 
    uint64_t             entry; 
    std::vector<Section> sections; 
    std::vector<Symbol>  symbols; 
    Binary(/* args */) : type(BinaryType::BIN_TYPE_AUTO), arch(BinaryArch::ARCH_NONE), bits(0), entry(0){};
    ~Binary();
    Section *get_text_section()
    {
        for (auto &i : sections)
        {
            if (i.name == ".text")
            {
                return &i;
            }
            return NULL;
        }
    }
};

int load_binary(std::string &fname, Binary *bin, BinaryType type);
void unload_binary(Binary *bin);


#endif





